package com.tiny.diamond;

import java.util.Map;

public interface DiamondClient {

    /**
     * @param request
     * @param <T>
     * @return
     * @throws DiamondApiException
     */
    <T extends DiamondResponse> T execute(DiamondRequest<T> request) throws DiamondApiException;


    <T extends DiamondResponse> T execute(DiamondRequest<T> request, String authToken) throws DiamondApiException;


    <T extends DiamondResponse> T execute(DiamondRequest<T> request, String authToken, String appAuthToken) throws DiamondApiException;


    <T extends DiamondResponse> T pageExecute(DiamondRequest<T> request) throws DiamondApiException;


    <T extends DiamondResponse> T pageExecute(DiamondRequest<T> request, String method) throws DiamondApiException;


    /**
     * SDK客户端调用生成sdk字符串
     *
     * @param <T>
     * @param request
     * @return
     * @throws DiamondApiException
     */
    <T extends DiamondResponse> T sdkExecute(DiamondRequest<T> request) throws DiamondApiException;


    /**
     * 移动客户端同步结果返回解析的参考工具方法
     *
     * @param result       移动客户端SDK同步返回的结果map，一般包含resultStatus，result和memo三个key
     * @param requsetClazz 接口请求request类，如App支付传入 AlipayTradeAppPayRequest.class
     * @return 同步返回结果的response对象
     * @throws DiamondApiException
     */
    public <TR extends DiamondResponse, T extends DiamondRequest<TR>> TR parseAppSyncResult(Map<String, String> result, Class<T> requsetClazz) throws DiamondApiException;
}
